﻿using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using eTMS.UpdateServices;

namespace eTMS.UpdateServerServices
{
    public class ServiceEntry
    {

        private List<ServiceHost> listServices = new List<ServiceHost>();

        private void AddService(ServiceHost service)
        {
            listServices.Add(service);
            service.Open();
            //progress.Increment(1);
            // Application.DoEvents();
        }

        public void StartServices()
        {
            ServiceHost service = new ServiceHost(typeof(UpdateService));
            UpdateService.RootPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            AddService(service);

        }
     
        public void CloseServices()
        {
            foreach (ServiceHost service in listServices)
            {
                service.Close();
                //progress.Increment(1);
                //Application.DoEvents();
            }
            listServices.Clear();
        }
    }
}
